package noentitywithoutassociation;

import org.eclipse.emf.ecore.EObject;

import org.eclipse.viatra2.emf.incquery.validation.runtime.Constraint;
import org.eclipse.viatra2.emf.incquery.validation.runtime.ValidationUtil;
import org.eclipse.viatra2.emf.incquery.runtime.api.impl.BaseGeneratedMatcherFactory;
import noentitywithoutassociation.NoEntityWithoutAssociationMatch;
import noentitywithoutassociation.NoEntityWithoutAssociationMatcherFactory;
import noentitywithoutassociation.NoEntityWithoutAssociationMatcher;

public class NoEntityWithoutAssociationConstraint extends Constraint<NoEntityWithoutAssociationMatch> {

	private NoEntityWithoutAssociationMatcherFactory matcherFactory;

	public NoEntityWithoutAssociationConstraint() {
		matcherFactory = new NoEntityWithoutAssociationMatcherFactory();
	}

	@Override
	public String getMessage() {
		return "Dude, $entity.name$ is not connected to any other entity!";
	}

	@Override
	public EObject getLocationObject(NoEntityWithoutAssociationMatch signature) {
		Object location = signature.get("entity");
		if(location instanceof EObject){
			return (EObject) location;
		}
		return null;
	}
	
	@Override
	public int getSeverity() {
		return ValidationUtil.getSeverity("warning");
	}
	
	@Override
	public BaseGeneratedMatcherFactory<NoEntityWithoutAssociationMatch, NoEntityWithoutAssociationMatcher> getMatcherFactory() {
		return matcherFactory;
	}
}
